package com.nanhang.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nanhang.booksearch.BookIS0;
import com.nanhang.booksearch.ReaderS0;
import com.nanhang.entity.Bookinfo;
import com.nanhang.entity.Reader;
import com.nanhang.mapper.ReaderMapper;
import com.nanhang.service.IReaderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import util.PageResult;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ymm
 * @since 2025-01-09
 */
@Service
public class ReaderServiceImpl extends ServiceImpl<ReaderMapper, Reader> implements IReaderService {
    @Override
    public PageResult<Reader> search(Integer page, Integer pagesize, ReaderS0 RS0){
        QueryWrapper<Reader> re =new QueryWrapper<>();
        re.like(StrUtil.isNotBlank(RS0.getRname()),"rname",RS0.getRname());
        re.like(StrUtil.isNotBlank(RS0.getSex()),"sex",RS0.getSex());
        re.eq(RS0.getAge() != null && RS0.getAge() != 0,"isbn",RS0.getAge());

        Page<Reader> repage = this.page(new Page<>(page,pagesize),re);

        return new PageResult<>(repage.getRecords(),repage.getTotal());
    }
}
